$new_array = []; foreach ($myarray as $key => $value) { if ($value->catid == 29) { $new_array[] = $value; unset($myarray[$key]); } }